package com.example.smartcity.ui.guide;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;

import com.bumptech.glide.Glide;
import com.example.smartcity.R;
import com.youth.banner.Banner;
import com.youth.banner.adapter.BannerImageAdapter;
import com.youth.banner.holder.BannerImageHolder;
import com.youth.banner.indicator.RectangleIndicator;
import com.youth.banner.listener.OnBannerListener;
import com.youth.banner.listener.OnPageChangeListener;

import java.util.ArrayList;

public class Guide extends AppCompatActivity {

    ArrayList<Integer> guides = new ArrayList<>();
    private Banner Banner_Guide;
    private TextView TV_SetPort,TV_SofterWare;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        guides.add(R.drawable.guide1);
        guides.add(R.drawable.guide2);
        guides.add(R.drawable.guide3);
        guides.add(R.drawable.guide4);
        guides.add(R.drawable.guide5);
        Banner_Guide = findViewById(R.id.Banner_Guide);
        TV_SetPort = findViewById(R.id.TV_SetPort);
        TV_SofterWare = findViewById(R.id.TV_SofterWare);
        initBanner();
        login();
        setPort();
    }

    public void initBanner(){
        Banner_Guide.setAdapter(new BannerImageAdapter<Integer>(guides) {
            @Override
            public void onBindView(BannerImageHolder bannerImageHolder, Integer integer, int i, int i1) {
                Glide.with(getBaseContext()).load(integer).into(bannerImageHolder.imageView);
            }
        }).setIndicator(new RectangleIndicator(getBaseContext()))
                .isAutoLoop(false)
                .start();
        Banner_Guide.addOnPageChangeListener(new OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {
                if (i==guides.size()-1){
                    TV_SetPort.setVisibility(View.VISIBLE);
                    TV_SofterWare.setVisibility(View.VISIBLE);
                }else{
                    TV_SetPort.setVisibility(View.GONE);
                    TV_SofterWare.setVisibility(View.GONE);
                }
            }
            @Override
            public void onPageSelected(int i) {

            }

            @Override
            public void onPageScrollStateChanged(int i) {

            }
        });
    }

    public void setPort(){
        TV_SetPort.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Guide.this,SetPort.class);
                startActivity(intent);
            }
        });
    }

    public void login(){
        TV_SofterWare.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Guide.this,login.class);
                startActivity(intent);
            }
        });
    }
}